#version 330 core
in vec4 fragColor;
in float radius;

out vec4 FragColor;

uniform float maxRadius;
uniform float middleColorRadius;

uniform float borderBrightness;
uniform float centerBrightness;

float interp(float edge0, float edge1, float edge0Val, float edge1Val, float x) {
    float y = ((edge1 - x) * edge0Val + (x - edge0) * edge1Val) / (edge1 - edge0);
    return y;
}

void main() {
    float brightness = (radius > middleColorRadius) ? interp(maxRadius, middleColorRadius, borderBrightness, 1.0, radius) : interp(middleColorRadius, 0.0, 1.0, centerBrightness, radius);
    FragColor = fragColor * brightness;
}